<?php

declare (strict_types=1);
/**
 * @copyright 深圳市易果网络科技有限公司
 * @version 1.0.0
 * @link https://dayiguo.com
 */

namespace App\Dao;

use App\Kernel\Traits\DaoTrait;
use App\Model\Payment;

/**
 * class
 *
 * @author 谢声强(861167322@qq.com)
 * @package App\Dao
 */
class PaymentDao extends Dao
{
    use DaoTrait;

    public function model(): string
    {
        return Payment::class;
    }

    /**
     * 查出该记录，不存在则创建
     *
     * @param array $condition
     * @param array $data
     * @return mixed
     */
    public function firstOrCreate(array $condition, array $data)
    {
        return self::makeModel()->firstOrCreate($condition, $data);
    }

    /**
     * 通过条件查询订单支付数据
     * @param array $map
     * @return mixed
     */
    public function getPaymentByMap(array $map)
    {
        return Payment::query()
            ->where(function ($query) use ($map) {
                return queryWhere($query, $map);
            })
            ->first();
    }
}